# simple talking

#Import math Library
import math

def get_dict_of_dividers(N):
    
    dd = {}
    maxd = int(math.sqrt(N)) + 1
    d = 2
    while d < maxd:
        if N % d == 0:
            if d not in dd:
                dd[d] = 0
            dd[d] += 1
            N = N // d
            maxd = int(math.sqrt(N)) + 1
            continue
        d += 1
    if N not in dd:
        dd[N] = 0
    dd[N] += 1
    
    return dd

def Euler_formula(n, dd):
    t = n
    for i in dd:
        t = int(t * (1 - 1/i))
    return t

def work_cycle(n):
    if n == 1:
        print(2)
    else:
        dd = get_dict_of_dividers(n)
        if n in dd:
            print(n-1)
        else:
            print(Euler_formula(n, dd))
            
n = int(input())
work_cycle(n)
    
# empty string
